<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="联系电话" prop="phone">
        <el-input
          v-model="queryParams.phone"
          placeholder="请输入联系电话"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="联系人" prop="relationName">
        <el-input
          v-model="queryParams.relationName"
          placeholder="请输入联系人"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
     
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="facebookList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="类型" align="center" prop="type">
		  <template #default="scope">
		  	 <span v-if="scope.row.type==1">房抵</span>
			 <span v-if="scope.row.type==2">赎楼</span>
			 <span v-if="scope.row.type==3">企业过桥</span>
			 <span v-if="scope.row.type==4">专项垫资</span>
			 <span v-if="scope.row.type==5">居间服务</span>
			 <span v-if="scope.row.type==6">工商需求</span>
		  </template>
	  </el-table-column>
      <el-table-column label="联系电话" align="center" prop="phone" />
      <el-table-column label="联系人" align="center" prop="relationName" />
      <el-table-column label="金额(元)" align="center" prop="amount" />
      <el-table-column label="地址" align="center" prop="address" />
      <el-table-column label="提交时间" align="center" prop="createTime" />
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />


  </div>
</template>

<script setup name="Facebook">
import { listFacebook } from "@/api/system/facebook";

const { proxy } = getCurrentInstance();

const facebookList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    type: null,
    phone: null,
    relationName: null,
    amount: null,
    address: null,
  },
  rules: {
  }
});

const { queryParams, form, rules } = toRefs(data);

/** 查询【请填写功能名称】列表 */
function getList() {
  loading.value = true;
  listFacebook(queryParams.value).then(response => {
    facebookList.value = response.rows;
    total.value = Number(response.total);
    loading.value = false;
  });
}

// 取消按钮
function cancel() {
  open.value = false;
  reset();
}

// 表单重置
function reset() {
  form.value = {
    id: null,
    type: null,
    phone: null,
    relationName: null,
    amount: null,
    address: null,
    createTime: null
  };
  proxy.resetForm("facebookRef");
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}



getList();
</script>
